From 812298d382befd9da83db94b931d30ceb0f39cd3 Mon Sep 17 00:00:00 2001 From: Tim Deegan Date: Tue, 26 Jul 2011 17:00:24 +0100 Subject: [PATCH] Nested VMX: always mark VVMCS as not-launched on VMCLEAR. The SDM says to flush changes and clear the launch state even if this isn't the "current VMCS". KVM relies on this behaviour, so take the warning printk away as well. Signed-off-by: Tim Deegan --- xen/arch/x86/hvm/vmx/vvmx.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/xen/arch/x86/hvm/vmx/vvmx.c b/xen/arch/x86/hvm/vmx/vvmx.c index 3ca1a267bd..942fd49d13 100644 --- a/xen/arch/x86/hvm/vmx/vvmx.c +++ b/xen/arch/x86/hvm/vmx/vvmx.c @@ -1162,6 +1162,7 @@ int nvmx_handle_vmclear(struct cpu_user_regs *regs) struct vmx_inst_decoded decode; struct nestedvcpu *nvcpu = &vcpu_nestedhvm(v); unsigned long gpa = 0; + void *vvmcs; int rc; rc = decode_vmx_inst(regs, &decode, &gpa, 0); @@ -1171,24 +1172,24 @@ int nvmx_handle_vmclear(struct cpu_user_regs *regs) if ( gpa & 0xfff ) { vmreturn(regs, VMFAIL_INVALID); - goto out; + return X86EMUL_OKAY; } - - if ( gpa != nvcpu->nv_vvmcxaddr && nvcpu->nv_vvmcxaddr != VMCX_EADDR ) + + if ( gpa == nvcpu->nv_vvmcxaddr ) { - gdprintk(XENLOG_WARNING, - "vmclear gpa %lx not the same as current vmcs %"PRIpaddr"\n", - gpa, nvcpu->nv_vvmcxaddr); - vmreturn(regs, VMSUCCEED); - goto out; - } - if ( nvcpu->nv_vvmcxaddr != VMCX_EADDR ) __set_vvmcs(nvcpu->nv_vvmcx, NVMX_LAUNCH_STATE, 0); - nvmx_purge_vvmcs(v); + nvmx_purge_vvmcs(v); + } + else + { + /* Even if this VMCS isn't the current one, we must clear it. */ + vvmcs = hvm_map_guest_frame_rw(gpa >> PAGE_SHIFT); + if ( vvmcs ) + __set_vvmcs(vvmcs, NVMX_LAUNCH_STATE, 0); + hvm_unmap_guest_frame(vvmcs); + } vmreturn(regs, VMSUCCEED); - -out: return X86EMUL_OKAY; } -- 2.30.2